package controllers;

//import com.sun.xml.internal.ws.wsdl.parser.Message;

import controllers.api.API;
import controllers.api.Users;

import models.User;
import play.mvc.Controller;
import play.data.validation.Error;
import play.data.validation.Required;
public class Registracia extends Controller {
	public static void reg() {
        render();
    }
	public static void create(){
		User user = new User();
		
		user.setName(request.params.get("name"));
		user.setName(request.params.get("name"));
		user.setEmail(request.params.get("email"));
		user.setGroup(request.params.get("group"));
		user.setPassword(request.params.get("password"));
		
		validation.required(request.params.get("name"));
		validation.minSize(request.params.get("name"),3);
		validation.required(request.params.get("surname"));
		validation.minSize(request.params.get("surname"), 3);
		validation.required(request.params.get("email"));
		validation.email(request.params.get("email"));
		validation.required(request.params.get("password"));
        validation.minSize(request.params.get("password"), 6);
        validation.required(request.params.get("passwordConfirm"));
        validation.equals(request.params.get("passwordConfirm"),request.params.get("password"));
        if(validation.hasErrors()){
        	params.flash();
        	flash.error("Oops..");
       	System.out.println("eror");
        	validation.keep();
        	 reg();
        	
        }
       
        else{ System.out.println("ok");
       //user.save();
        }
       
        		
	}

}
